package com.hbsc.config;

import com.hbsc.interceptor.RightsHandlerInterceptor;
import com.hbsc.interceptor.WiXinHandlerInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

import java.util.Properties;

/**
 * Created by xudong on 2017-10-18.
 */
@Configuration
public class WebAppConfigurer extends WebMvcConfigurerAdapter {
    @Bean
    public RightsHandlerInterceptor rightsHandlerInterceptor() {
        return new RightsHandlerInterceptor();
    }

    @Bean
    public WiXinHandlerInterceptor weixinHandlerInterceptor() {
        return new WiXinHandlerInterceptor();
    }

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(rightsHandlerInterceptor()).addPathPatterns("/*");
        registry.addInterceptor(weixinHandlerInterceptor()).addPathPatterns("/test/**");
        super.addInterceptors(registry);
    }
/*    @Bean
    public PageHelper pageHelper(){
             PageHelper pageHelper = new PageHelper();
             Properties properties = new Properties();
             properties.setProperty("offsetAsPageNum","true");
             properties.setProperty("rowBoundsWithCount","true");
             properties.setProperty("reasonable","true");
             properties.setProperty("dialect","mysql");
             pageHelper.setProperties(properties);
             return pageHelper;
    }*/
}
